package Demo1299.Demo6;

import org.apache.commons.io.FileUtils;

import java.io.File;
import java.lang.reflect.Field;
import java.util.List;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        String str = FileUtils.readFileToString(new File("C:\\Daymate\\src\\Demo1299\\Demo6\\data1.txt"));
        List<String> list = FileUtils.readLines(new File("C:\\Daymate\\src\\Demo1299\\Demo6\\data2.txt"));
        Class<?> aClass = Class.forName(str);
        Object person = aClass.getDeclaredConstructor().newInstance();
        Field id = aClass.getDeclaredField("id");
        id.setAccessible(true);
        id.set(person,list.get(0).split("=")[1]);
        Field name = aClass.getDeclaredField("name");
        name.setAccessible(true);
        name.set(person,list.get(1).split("=")[1]);
        Field age = aClass.getDeclaredField("age");
        age.setAccessible(true);
        age.set(person,Integer.parseInt(list.get(2).split("=")[1]));
        System.out.println(person);
    }
}
